public class CountableWord implements Comparable<CountableWord>
{
    private final String word;
    private final Integer count;

    CountableWord(String word, Integer count)
    {
        this.word = word;
        this.count = count;
    }

    public Integer getCount()
    {
        return count;
    }

    public String getWord()
    {
        return word;
    }

    @Override
    public int compareTo(CountableWord o)
    {
        if (!count.equals(o.getCount()))
        {
            return -count.compareTo(o.getCount());
        }
        else
        {
            return word.compareTo(o.getWord());
        }
    }
}
